home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / bin / DXUtils / AppWizard / DXAppwiz.awx / TEMPLATE / DXUTIL.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-25  |  5.0 KB  |  111 lines

  1. //-----------------------------------------------------------------------------
  2. // File: DXUtil.h
  3. //
  4. // Desc: Helper functions and typing shortcuts for DirectX programming.
  5. //-----------------------------------------------------------------------------
  6. #ifndef DXUTIL_H
  7. #define DXUTIL_H
  8.  
  9.  
  10. //-----------------------------------------------------------------------------
  11. // Miscellaneous helper functions
  12. //-----------------------------------------------------------------------------
  13. #define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
  14. #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
  15. #define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
  16.  
  17.  
  18.  
  19.  
  20. //-----------------------------------------------------------------------------
  21. // Name: DXUtil_GetDXSDKMediaPath() and DXUtil_FindMediaFile() 
  22. // Desc: Returns the DirectX SDK path, as stored in the system registry
  23. //       during the SDK install.
  24. //-----------------------------------------------------------------------------
  25. const TCHAR* DXUtil_GetDXSDKMediaPath();
  26. HRESULT      DXUtil_FindMediaFile( TCHAR* strPath, TCHAR* strFilename );
  27.  
  28.  
  29.  
  30.  
  31. //-----------------------------------------------------------------------------
  32. // Name: DXUtil_Read*RegKey() and DXUtil_Write*RegKey()
  33. // Desc: Helper functions to read/write a string registry key 
  34. //-----------------------------------------------------------------------------
  35. HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
  36. HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
  37. HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
  38. HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );
  39.  
  40. HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
  41. HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
  42. HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
  43. HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
  44.  
  45.  
  46.  
  47.  
  48. //-----------------------------------------------------------------------------
  49. // Name: DXUtil_Timer()
  50. // Desc: Performs timer opertations. Use the following commands:
  51. //          TIMER_RESET           - to reset the timer
  52. //          TIMER_START           - to start the timer
  53. //          TIMER_STOP            - to stop (or pause) the timer
  54. //          TIMER_ADVANCE         - to advance the timer by 0.1 seconds
  55. //          TIMER_GETABSOLUTETIME - to get the absolute system time
  56. //          TIMER_GETAPPTIME      - to get the current time
  57. //          TIMER_GETELAPSEDTIME  - to get the time that elapsed between 
  58. //                                  TIMER_GETELAPSEDTIME calls
  59. //-----------------------------------------------------------------------------
  60. enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
  61.                      TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
  62. FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
  63.  
  64.  
  65.  
  66.  
  67. //-----------------------------------------------------------------------------
  68. // UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
  69. //-----------------------------------------------------------------------------
  70. VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
  71. VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
  72. VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
  73. VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
  74. VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
  75. VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
  76.  
  77.  
  78.  
  79.  
  80. //-----------------------------------------------------------------------------
  81. // GUID to String converting 
  82. //-----------------------------------------------------------------------------
  83. VOID DXUtil_ConvertGUIDToString( const GUID* pGuidIn, TCHAR* strOut );
  84. BOOL DXUtil_ConvertStringToGUID( const TCHAR* strIn, GUID* pGuidOut );
  85.  
  86.  
  87.  
  88.  
  89. //-----------------------------------------------------------------------------
  90. // Debug printing support
  91. //-----------------------------------------------------------------------------
  92. VOID    DXUtil_Trace( TCHAR* strMsg, ... );
  93. HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
  94.  
  95. #if defined(DEBUG) | defined(_DEBUG)
  96.     #define DXTRACE           DXUtil_Trace
  97. #else
  98.     #define DXTRACE           sizeof
  99. #endif
  100.  
  101. #if defined(DEBUG) | defined(_DEBUG)
  102.     #define DEBUG_MSG(str)    _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
  103. #else
  104.     #define DEBUG_MSG(str)    (0L)
  105. #endif
  106.  
  107.  
  108.  
  109.  
  110. #endif // DXUTIL_H
  111.